home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / rxdoscmd.zip / RXDOSCPY.ASM < prev    next >
Assembly Source File  |  1993-06-06  |  29KB  |  695 lines

  1.         TITLE   'Copy - RxDOS Command Shell Copy'
  2.         PAGE 59, 132
  3.         .LALL
  4.  
  5.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  6.         ;  RxDOS Command Shell Copy                                     ;
  7.         ;...............................................................;
  8.  
  9.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  10.         ;  Real Time Dos                                                ;
  11.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  12.         ;                                                               ;
  13.         ;  This material  was created as a published version  of a DOS  ;
  14.         ;  equivalent product.   This program  logically  functions in  ;
  15.         ;  the same way as  MSDOS functions and it  is  internal  data  ;
  16.         ;  structure compliant with MSDOS 5.0                           ;
  17.         ;                                                               ;
  18.         ;  This product is distributed  AS IS and contains no warranty  ;
  19.         ;  whatsoever,   including  warranty  of   merchantability  or  ;
  20.         ;  fitness for a particular purpose.                            ;
  21.         ;                                                               ;
  22.         ;                                                               ;
  23.         ;  (c) Copyright 1990, 1992. Api Software and Mike Podanoffsky  ;
  24.         ;      All Rights Reserved Worldwide.                           ;
  25.         ;                                                               ;
  26.         ;  This product is protected under copyright laws and  may not  ;
  27.         ;  be reproduced  in whole  or in part, in any form  or media,  ;
  28.         ;  included but not limited to source listing, facimilie, data  ;
  29.         ;  transmission, cd-rom, or  floppy disk without the expressed  ;
  30.         ;  written consent of the author.                               ;
  31.         ;                                                               ;
  32.         ;  Licence for distribution in commercial use:                  ;
  33.         ;                                                               ;
  34.         ;  Api Software                                                 ;
  35.         ;  12 South Walker Street                                       ;
  36.         ;  Lowell,  MA   01851                                          ;
  37.         ;  508/ 454-4961.                                               ;
  38.         ;                                                               ;
  39.         ;...............................................................;
  40.  
  41.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  42.         ;  RxDOS Command Shell                                          ;
  43.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  44.         ;                                                               ;
  45.         ;  Programmer's Notes:                                          ;
  46.         ;                                                               ;
  47.         ;  Command Shell consists of  two parts bound  together into a  ;
  48.         ;  single executable load.  There  exists  a  single  resident  ;
  49.         ;  command shell which is accessible by an Int 2Eh.             ;
  50.         ;                                                               ;
  51.         ;...............................................................;
  52.  
  53.         include rxdosmac.asm
  54.         include rxdosdef.asm
  55.         include rxdoscin.asm
  56.  
  57.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  58.         ;  RxDOS Command Shell                                          ;
  59.         ;...............................................................;
  60.  
  61. RxDOSCMD SEGMENT PUBLIC 'CODE'
  62.          assume cs:RxDOSCMD, ds:RxDOSCMD, es:RxDOSCMD, ss:RxDOSCMD
  63.  
  64.         public _Copy
  65.  
  66.         extrn CmndError_BadSwitch                       : near
  67.         extrn CmndError_CannotCopyUntoSelf              : near
  68.         extrn CmndError_CannotCreateFile                : near
  69.         extrn CmndError_ContentsLostBeforeCopy          : near
  70.         extrn CmndError_FileNotFound                    : near
  71.         extrn CountArgs                                 : near
  72.         extrn CRLF                                      : near
  73.         extrn deleteArg                                 : near
  74.         extrn DisplayError                              : near
  75.         extrn DisplayErrorMessage                       : near
  76.         extrn DisplayLine                               : near
  77.         extrn RxDOS_DTA                                 : near
  78.         extrn RxDOS_AllFiles                            : near
  79.  
  80.         extrn _AppendPathName                           : near
  81.         extrn _CopyString                               : near
  82.         extrn _Copy_FilesCopied                         : near
  83.         extrn _CmndParse_Break                          : near
  84.         extrn _lowerCase                                : near
  85.         extrn _SwitchChar                               : near
  86.         extrn _splitpath                                : near
  87.         extrn _makePath                                 : near
  88.  
  89.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  90.         ;  Copy filenameA+filenameB+filenameC filenameDest              ;
  91.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  92.         ;                                                               ;
  93.         ;  Usage:                                                       ;
  94.         ;   ss:di  Arg Array                                            ;
  95.         ;   ax     Number of arguments in array                         ;
  96.         ;...............................................................;
  97.  
  98. _Copy:
  99.  
  100.         Entry
  101.         def __argarray, di                              ; args array
  102.         def __numArgs, ax                               ; # args
  103.         def __Mode, 0000                                ; non-z if ascii/ z if binary
  104.         def __AddMode                                   ; 0000 not add mode
  105.         def __NextAddMode                               ; 0000 next is add mode
  106.         def _endoffile
  107.         def _filesCopies, 0000
  108.         def _srcHandle  , 0000
  109.         def _destHandle , 0000
  110.         ddef _destCluster
  111.         ddef _srcCluster
  112.  
  113.         defbytes _destFilename  , 130
  114.         defbytes _createFilename, 130
  115.         defbytes _copyFilename  , 130
  116.         defbytes _buffer, 128
  117.  
  118.         _tempFilename = _copyFilename                   ; equate temp filename
  119.  
  120. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  121. ;  get/test destination filename
  122. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  123.  
  124.         cmp ax, 2                                       ; must have at least two args
  125.         ifc _copyError                                  ; any less means error -->
  126.  
  127.         dec ax
  128.         add ax, ax                                      ; args offset in words
  129.         add di, ax                                      ; point to last arg
  130.         push word ptr [ di ]                            ; get last arg address
  131.         call deleteArg
  132.  
  133.         pop si
  134.         lea di, offset [ _tempFilename ][ bp ]
  135.         call _copyArgument                              ; copy argument
  136.  
  137. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  138. ;  see if dest is just a directory name
  139. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  140.  
  141.         mov cx, ATTR_DIRECTORY
  142.         lea dx, offset [ _tempFilename ][ bp ]
  143.         Int21 FindFirstFile                             ; locate file with name
  144.         jc _Copy_18                                     ; not a directory -->
  145.  
  146.     ;  if . or .. handle special
  147.  
  148. _Copy_08:
  149.         test byte ptr [ RxDOS_DTA. findFileAttribute ], ATTR_DIRECTORY
  150.         jz _Copy_18                                     ; if not a dir entry -->
  151.  
  152.         cmp byte ptr [ RxDOS_DTA. findFileName ], '.'
  153.         jnz _Copy_24                                    ; if dir and not . or .. -->
  154.  
  155.         Int21 FindNextFile                              ; locate next file
  156.         jnc _Copy_08                                    ; see if also a dir -->
  157.  
  158. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  159. ;  scan name for just directory
  160. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  161.  
  162. _Copy_18:
  163.         lea di, offset [ _tempFilename ][ bp ]
  164.  
  165. _Copy_20:
  166.         cmp byte ptr [ di ], 00                         ; null ?
  167.         jz _Copy_26                                     ; yes, done -->
  168.         inc di
  169.         cmp byte ptr [ di-1 ], ':'                      ; only drive /colon entered ?
  170.         jnz _Copy_20                                    ; no -->
  171.         cmp byte ptr [ di ], 00                         ; 
  172.         jnz _Copy_26
  173.  
  174. _Copy_24:
  175.         mov si, offset RxDOS_AllFiles                   ; dummy path 
  176.         call _AppendPathName                            ; append all files
  177.  
  178. _Copy_26:
  179.         lea si, offset [ _tempFilename ][ bp ]
  180.         lea di, offset [ _destFilename ][ bp ]          ; expansion area
  181.         mov byte ptr [ di ], '\'                        ; (in case no output generated)
  182.         Int21 GetActualFileName                         ; expand name
  183.         ifc _copyError                                  ; destination doesn't exist -->
  184.  
  185.         xor ax, ax
  186.         mov cx, 4
  187.         lea di, offset [ _destCluster ][ bp ]           ; clusters
  188.         rep stosw                                       ; clear clusters
  189.  
  190. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  191. ;  main loop through all args
  192. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  193.  
  194. _Copy_30:
  195.         mov word ptr [ __AddMode  ][ bp ], 0000         ; not add mode
  196.         mov word ptr [ __NextAddMode  ][ bp ], 0000     ; next is not add mode
  197.  
  198. _Copy_32:
  199.         mov di, word ptr [ __argarray ][ bp ]           ; get arg pointer to next arg
  200.         mov si, word ptr [ di ]                         ; point to text 
  201.         or si, si                                       ; null entry ?
  202.         ifz _Copy_Return                                ; yes, return -->
  203.  
  204.         add word ptr [ __argarray ][ bp ], 2            ; skip this argument next time
  205.  
  206.         mov al, byte ptr [ si ]
  207.         cmp al, byte ptr [ _SwitchChar ]                ; switch ?
  208.         ifz _Copy_TestSwitch                            ; yes, go test switch -->
  209.  
  210.         cmp al, '+'
  211.         ifz _Copy_AddMode                               ; set add mode -->
  212.  
  213.         lea di, offset [ _copyFilename ][ bp ]
  214.         call _copyArgument
  215.  
  216.         call _scanForwardArgArray                       ; see if followed by +
  217.         mov word ptr [ __NextAddMode  ][ bp ], ax       ; next add mode
  218.  
  219.         mov dx, di                                      ; copy filename
  220.         mov cx, ATTR_NORMAL   
  221.         Int21 FindFirstFile                             ; locate file with name
  222.         jnc _Copy_36                                    ; if file found -->
  223.  
  224.         mov dx, offset CmndError_FileNotFound
  225.         call DisplayLine
  226.         jmp _copyErrorCleanUp
  227.  
  228. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  229. ;  open source file
  230. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  231.  
  232. _Copy_36:
  233.         lea di, offset [ _copyFilename ][ bp ]
  234.         call _replaceWithRealName
  235.  
  236.         Int21 OpenFile, OPEN_ACCESS_READONLY
  237.         storarg _srcHandle, ax
  238.         ifc _copyError
  239.  
  240.         mov bx, ax
  241.         call GetClusterValue                            ; src cluster
  242.         mov word ptr [ _srcCluster. _low  ][ bp ], ax   ; (cluster)
  243.         mov word ptr [ _srcCluster. _high ][ bp ], dx   ; (drive )
  244.         jz _Copy_44                                     ; if not a file -->
  245.  
  246.         call _compareClusters
  247.         jnz _Copy_44                                    ; no -->
  248.  
  249.     ; error: file destroyed
  250.  
  251.         mov dx, offset CmndError_ContentsLostBeforeCopy
  252.         call DisplayErrorMessage
  253.         jmp _copyErrorCleanUp
  254.  
  255. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  256. ;  attempt create file
  257. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  258.  
  259. _Copy_44:
  260.         getarg bx, _destHandle
  261.         or bx, bx                                       ; any dest file ?
  262.         jz _Copy_48                                     ; no, MUST create -->
  263.         cmp word ptr [ __AddMode  ][ bp ], 0000         ; add mode ?
  264.         jnz _Copy_56                                    ; yes, append to existing file -->
  265.  
  266. _Copy_48:
  267.         lea si, offset [ _destFilename ][ bp ]          ; destination filename
  268.         lea di, offset [ _createFilename ][ bp ]        ; make destination name
  269.         call _CopyString                                ; copy string
  270.  
  271.         lea di, offset [ _createFilename ][ bp ]        ; make destination name
  272.         call _makeUniqueName                            ; make unique name
  273.  
  274.         lea dx, offset [ _createFilename ][ bp ]        ; destination filename
  275.         Int21 OpenFile, OPEN_ACCESS_READONLY            ; we'll try open first
  276.         jc _Copy_52                                     ; MUST create -->
  277.  
  278.         mov bx, ax
  279.         call GetClusterValue                            ; cluster of dest
  280.         mov word ptr [ _destCluster. _low  ][ bp ], ax  ; (cluster)
  281.         mov word ptr [ _destCluster. _high ][ bp ], dx  ; (drive )
  282.         Int21 CloseFile                                 ; release file
  283.  
  284.         call _compareClusters
  285.         jnz _Copy_52                                    ; if not same files -->
  286.  
  287.         mov dx, offset CmndError_CannotCopyUntoSelf
  288.         call DisplayErrorMessage
  289.         jmp _copyErrorCleanUp
  290.  
  291. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  292. ;  create file
  293. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  294.  
  295. _Copy_52:
  296.         mov cx, ATTR_NORMAL
  297.         lea dx, offset [ _createFilename ][ bp ]        ; destination filename
  298.         Int21 CreateFile                                ; this is wrong (must try open first)
  299.         storarg _destHandle, ax
  300.         ifc _copyError
  301.  
  302.         mov bx, ax
  303.         call GetClusterValue                            ; cluster of dest
  304.         mov word ptr [ _destCluster. _low  ][ bp ], ax  ; (cluster)
  305.         mov word ptr [ _destCluster. _high ][ bp ], dx  ; (drive )
  306.  
  307. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  308. ;  display filename
  309. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  310.  
  311. _Copy_56:
  312.         mov word ptr [ _endoffile ][ bp ], 0000
  313.  
  314.         getarg bx, _srcHandle
  315.         Int21 IoControl, 0000                           ; is source a char device ?
  316.         test dx, DEV_CHAR                               ; test device flag
  317.         jz _Copy_62                                     ; if file, display filename -->
  318.         storarg __Mode, 01                              ; else switch to ascii mode
  319.         jmp short _Copy_66
  320.  
  321. _Copy_62:
  322.         mov dx, offset [ RxDOS_DTA. findFileName ]
  323.         call DisplayLine                                ; display line
  324.         call CRLF                                       ; cr/lf
  325.  
  326. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  327. ;  copy loop
  328. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  329.  
  330. _Copy_66:
  331.         mov cx, 128
  332.         getarg bx, _srcHandle
  333.         lea dx, offset [ _buffer ][ bp ]
  334.         Int21 ReadFile                                  ; read 
  335.         ifc _copyDisplayError                           ; if error -->
  336.         or ax, ax                                       ; end of file ?
  337.         jz _Copy_78                                     ; yes, all done -->
  338.  
  339.         mov cx, ax                                      ; how many bytes actually read
  340.         cmp word ptr [ __Mode ][ bp ], 0000             ; ascii mode ?
  341.         jz _Copy_70                                     ; no -->
  342.  
  343.         push cx
  344.         mov al, 'Z'-40h
  345.         lea di, offset [ _buffer ][ bp ]
  346.         repnz scasb                                     ; scan buffer for ^Z
  347.         pop cx
  348.         jnz _Copy_70                                    ; if ^z not located ->
  349.  
  350.         mov word ptr [ _endoffile ][ bp ], -1           ; set end of file mode
  351.         dec cx                                          ; don't copy ^Z
  352.  
  353. _Copy_70:
  354.         or cx, cx                                       ; any more to copy ?
  355.         jz _Copy_78                                     ; no more -->
  356.  
  357.         getarg bx, _destHandle
  358.         lea dx, offset [ _buffer ][ bp ]
  359.         Int21 WriteFile
  360.  
  361.         cmp word ptr [ _endoffile ][ bp ], 0000         ; end of file ?
  362.         jz _Copy_66                                     ; not end of file yet -->
  363.  
  364. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  365. ;  close source file
  366. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  367.  
  368. _Copy_78:
  369.         getarg bx, _srcHandle
  370.         Int21 CloseFile
  371.         storarg _srcHandle, 0000
  372.  
  373.         cmp word ptr [ __NextAddMode  ][ bp ], 0000     ; is next add mode ?
  374.         jnz _Copy_82
  375.  
  376.         getarg bx, _destHandle
  377.         Int21 CloseFile                                 ; if no adds left ...
  378.         storarg _destHandle, 0000
  379.  
  380.         Int21 FindNextFile                              ; see if more files to copy
  381.         ifnc _Copy_36                                   ; if file found -->
  382.  
  383. _Copy_82:
  384.         jmp _Copy_30
  385.  
  386. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  387. ;  return
  388. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  389.  
  390. _Copy_Return:
  391.         inc word ptr [ _filesCopies ][ bp ]             ; # files copied.
  392.  
  393. _Copy_ReturnClose:
  394.         getarg bx, _destHandle
  395.         cmp bx, 5
  396.         jle _Copy_ReturnClose_08
  397.         Int21 CloseFile                                 ; close last file
  398.  
  399. _Copy_ReturnClose_08:
  400.         Return
  401.  
  402. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  403. ;  add mode
  404. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  405.  
  406. _Copy_AddMode:
  407.         mov word ptr [ __AddMode  ][ bp ], -1           ; set add mode
  408.         jmp _Copy_32
  409.  
  410. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  411. ;  test switches
  412. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  413.  
  414. _Copy_TestSwitch:
  415.         mov al, byte ptr [ si+1 ]
  416.         call _lowerCase                                 ; test switch option
  417.  
  418.         goto 'a', _copyAsciiSwitch
  419.         goto 'b', _copyBinarySwitch
  420.  
  421.         push ax
  422.         mov dx, offset CmndError_BadSwitch
  423.         call DisplayLine                                ; show error message
  424.  
  425.         pop dx
  426.         call DisplayLine                                ; show arg
  427.         Return
  428.  
  429. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  430. ;  if ascii switch
  431. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  432.  
  433. _copyAsciiSwitch:
  434.         storarg __Mode, 01                              ; ascii mode
  435.         jmp _Copy_32
  436.  
  437. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  438. ;  if binary switch
  439. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  440.  
  441. _copyBinarySwitch:
  442.         storarg __Mode, 00                              ; binary mode
  443.         jmp _Copy_32
  444.  
  445. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  446. ;  error in rename command
  447. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  448.  
  449. _copyDisplayError:
  450.         call DisplayError
  451.         jmp _copyErrorCleanUp
  452.  
  453. _copyError:
  454.         mov dx, offset CmndError_CannotCreateFile
  455.         call DisplayErrorMessage
  456.  
  457. _copyErrorCleanUp:
  458.         getarg bx, _destHandle
  459.         or bx, bx                                       ; if not assigned, 
  460.         jz _copyErrorCleanUp_08                         ; don't delete -->
  461.         Int21 CloseFile                                 ; close last file
  462.  
  463. _copyErrorCleanUp_08:
  464.         Return
  465.  
  466.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  467.         ;  Copy Argument                                                ;
  468.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  469.         ;                                                               ;
  470.         ;  Usage:                                                       ;
  471.         ;   si     points to argument start                             ;
  472.         ;   di     points to destination                                ;
  473.         ;...............................................................;
  474.  
  475. _copyArgument:
  476.  
  477.         push di
  478.  
  479. _copyArgument_06:
  480.         lodsb                                           ; get character 
  481.         stosb
  482.         cmp al, ' '+1                                   ; space or control character ?
  483.         jc _copyArgument_10                             ; yes -->
  484.  
  485.         cmp al, byte ptr [ _SwitchChar ]                ; switch character ?
  486.         jz _copyArgument_10                             ; yes -->
  487.         call _CmndParse_Break                           ; parse break ?
  488.         jnz _copyArgument_06                            ; no, go to next char -->
  489.  
  490. _copyArgument_10:
  491.         mov byte ptr [ di-1 ], 0                        ; place null terminator
  492.         pop di
  493.         ret
  494.  
  495.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  496.         ;  LookAhead Add Mode                                           ;
  497.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  498.         ;                                                               ;
  499.         ;  Usage:                                                       ;
  500.         ;   si     points to argument start                             ;
  501.         ;   di     points to destination                                ;
  502.         ;...............................................................;
  503.  
  504. _scanForwardArgArray:
  505.  
  506.         push di
  507.         mov di, word ptr [ __argarray ][ bp ]           ; get arg pointer to next arg
  508.         xor ax, ax                                      ; next is NOT add
  509.  
  510. _scanForwardArgArray_10:
  511.         mov si, word ptr [ di ]                         ; point to text 
  512.         or si, si                                       ; null entry ?
  513.         jz _scanForwardArgArray_12                      ; yes, return -->
  514.  
  515.         add di, 2
  516.         cmp byte ptr [ si ], '/'
  517.         jz _scanForwardArgArray_10
  518.         cmp byte ptr [ si ], '+'
  519.         jnz _scanForwardArgArray_12
  520.         mov ax, -1                                      ; next IS add
  521.  
  522. _scanForwardArgArray_12:
  523.         pop di
  524.         ret
  525.  
  526.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  527.         ;  Get Starting Cluster Value for a given Handle                ;
  528.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  529.         ;                                                               ;
  530.         ;  Input:                                                       ;
  531.         ;   bx     file handle                                          ;
  532.         ;                                                               ;
  533.         ;  Output:                                                      ;
  534.         ;   ax     starting cluster value                               ;
  535.         ;...............................................................;
  536.  
  537. GetClusterValue:
  538.  
  539.         push es
  540.         push di
  541.         push bx
  542.         Int21 GetPSPAddress                             ; returns bx with segment
  543.         mov es, bx                                      ; set PSP address
  544.  
  545.         pop si                                          ; restore handle offset
  546.         push si                                         ; (save handle)
  547.         les bx, dword ptr es:[ pspFileHandlePtr ]       ; point to file handles
  548.         mov bl, byte ptr es:[ bx + si ]                 ; get real sft offset
  549.         xor bh, bh
  550.  
  551.         mov ax, 1216h
  552.         int 2fh                                         ; UNDOCUMENTED DOS CALL
  553.         mov ax, word ptr es:[ sftBegCluster ][ di ]
  554.         mov dx, word ptr es:[ sftDevInfo    ][ di ]
  555.         and dx, sftDrivemask
  556.  
  557.         pop bx
  558.         pop di
  559.         pop es
  560.         ret
  561.  
  562.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  563.         ;  Compare Drive/Cluster Info                                   ;
  564.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  565.         ;                                                               ;
  566.         ;  NZ if not equal                                              ;
  567.         ;...............................................................;
  568.  
  569. _compareClusters:
  570.  
  571.         cmp word ptr [ _destCluster. _low  ][ bp ], 0000
  572.         jnz _compareClusters_NotEqual
  573.         cmp word ptr [ _srcCluster. _low  ][ bp ], 0000
  574.         jnz _compareClusters_NotEqual
  575.  
  576.         mov ax, word ptr [ _destCluster. _low  ][ bp ]  ; (cluster)
  577.         cmp ax, word ptr [ _srcCluster. _low ][ bp ]
  578.         jnz _compareClusters_NotEqual
  579.  
  580.         mov ax, word ptr [ _destCluster. _high ][ bp ]  ; (drive )
  581.         cmp ax, word ptr [ _srcCluster. _high ][ bp ]
  582.         jnz _compareClusters_NotEqual
  583.         ret
  584.  
  585. _compareClusters_NotEqual:
  586.         mov ax, -1
  587.         or ax, ax
  588.         ret
  589.  
  590.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  591.         ;  Make Unique Name                                             ;
  592.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  593.         ;                                                               ;
  594.         ;  Usage:                                                       ;
  595.         ;   di     name expected with wild characters                   ;
  596.         ;...............................................................;
  597.  
  598. _makeUniqueName:
  599.  
  600.         Entry
  601.         def _name, di
  602.         defbytes _expandedname, sizeExpandedName
  603.  
  604.         push di
  605.  
  606.         mov si, di
  607.         lea di, offset [ _expandedname ][ bp ]
  608.         call _splitpath
  609.  
  610.         mov cx, 8
  611.         mov si, offset [ RxDOS_DTA. findFileName ]
  612.         lea di, offset [ _expandedname. expFilename ][ bp ]
  613.         call _makeReplacement
  614.  
  615.         inc si
  616.         mov cx, 3
  617.         lea di, offset [ _expandedname. expExtension + 1 ][ bp ]
  618.         call _makeReplacement
  619.  
  620.         lea si, offset [ _expandedname ][ bp ]
  621.         getarg di, _name
  622.         call _makePath
  623.  
  624.         pop di
  625.         mov dx, di
  626.         Return
  627.  
  628.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  629.         ;  Make Replacement                                             ;
  630.         ;...............................................................;
  631.  
  632. _makeReplacement:
  633.  
  634.         cmp byte ptr [ di ], '?'
  635.         jnz _makeReplacement_08
  636.  
  637.         mov al, byte ptr [ si ]
  638.         mov byte ptr [ di ], al
  639.  
  640. _makeReplacement_08:
  641.         inc di
  642.         inc si
  643.         cmp byte ptr [ si ], '.'
  644.         jz _makeReplacement_12
  645.         cmp byte ptr [ si ], 00
  646.         jz _makeReplacement_12
  647.         loop _makeReplacement
  648.  
  649. _makeReplacement_12:
  650.         mov byte ptr [ di ], 00
  651.         ret
  652.  
  653.         ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
  654.         ;  Replace with Real Name                                       ;
  655.         ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  656.         ;                                                               ;
  657.         ;  Usage:                                                       ;
  658.         ;   di     full expanded name expected                          ;
  659.         ;...............................................................;
  660.  
  661. _replaceWithRealName:
  662.  
  663.         push di
  664.         mov dx, di
  665.  
  666. _replaceWithRealName_04:
  667.         cmp byte ptr [ di ], 0                          ; find end of string
  668.         jz _replaceWithRealName_08
  669.         inc di
  670.         jmp _replaceWithRealName_04
  671.  
  672. _replaceWithRealName_08:
  673.         cmp dx, di
  674.         jz _replaceWithRealName_12
  675.  
  676.         mov al, byte ptr [ di-1 ]
  677.         cmp al, ':'
  678.         jz _replaceWithRealName_12
  679.         cmp al, '\'
  680.         jz _replaceWithRealName_12
  681.  
  682.         dec di
  683.         jmp _replaceWithRealName_08
  684.  
  685. _replaceWithRealName_12:
  686.         mov si, offset [ RxDOS_DTA. findFileName ]      ; expanded name
  687.         call _CopyString
  688.  
  689.         pop di
  690.         mov dx, di
  691.         ret
  692.  
  693. RxDOSCMD                        ENDS
  694.                                 END
  695.